Make testsuite fail if we lack pixbuf loaders
authorMatthias Clasen <mclasen@redhat.com>
Fri, 26 Mar 2021 01:22:23 +0000 (21:22 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 26 Mar 2021 01:23:11 +0000 (21:23 -0400)
Add a test that requires that we have png and jpeg
loaders.

testsuite/gdk/meson.build
testsuite/gdk/pixbuf.c [new file with mode: 0644]

index cc3125de37c71a8b442fa28d914acdc56c96b636..5216d7a5183ab9deafe34140b536f98561fd6d26 100644 (file)
@@ -11,6 +11,7 @@ tests = [
   'encoding',
   'keysyms',
   'memorytexture',
+  'pixbuf',
   'rectangle',
   'rgba',
   'seat',
diff --git a/testsuite/gdk/pixbuf.c b/testsuite/gdk/pixbuf.c
new file mode 100644 (file)
index 0000000..592f5d0
--- /dev/null
@@ -0,0 +1,31 @@
+#include <gdk-pixbuf/gdk-pixbuf.h>
+
+int
+main (int argc, char *argv[])
+{
+  GSList *formats;
+  gboolean have_png, have_jpeg;
+
+  have_png = FALSE;
+  have_jpeg = FALSE;
+
+  formats = gdk_pixbuf_get_formats ();
+
+  for (GSList *l = formats; l; l = l->next)
+    {
+      GdkPixbufFormat *format = l->data;
+      const char *name;
+
+      name = gdk_pixbuf_format_get_name (format);
+
+      if (strcmp (name, "png") == 0)
+        have_png = TRUE;
+      else if (strcmp (name, "jpeg") == 0)
+        have_jpeg = TRUE;
+    }
+
+  if (!have_png || !have_jpeg)
+    return 1;
+
+  return 0;
+}